﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="format-detection" content="telephone=no" />
    <title>智慧团建系统-打卡中心</title>
    <link rel="icon" href="favicon.ico" mce_href="favicon.ico" type="image/x-icon">
	<link rel="shortcut icon" href="favicon.ico" mce_href="favicon.ico" type="image/x-icon">
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=IE8" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<meta http-equiv="Expires" content="0">
	<meta http-equiv="Pragma" content="no-cache">
	<meta http-equiv="Cache" content="no-cache">
	<meta http-equiv="kiben" content="no-cache">
	<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
	<!-- css -->
    <link rel="stylesheet" type="text/css"  href="asset/css/comm.css" />
    <link type="text/css" rel="stylesheet" charset="utf-8" href="asset/bootstrap/css/bootstrap.css">
    <link type="text/css" rel="stylesheet" charset="utf-8" href="asset/css/cys.css">
    <style type="text/css">
		.ng-cloak,
		.x-ng-cloak,
		.ng-hide {
			display: none !important;
		}
		ng:form {
			display: block;
		}
		.pull-right {
			float: right !important;
			display: inline-flex;
		}
		.searBOX .inpBox input.inptext, .searBOX .inpBox .selsty {
			width: auto;
		}
		.mainBOX{padding:10px 26px}
		.newTABLE, .cooBOX{margin-left:0;font-size:14px}
		.btn.addBtn{width:auto}
	</style>
</head>

<body class="qm_bgcolor">
	<div id="header_wrap"></div>
    <div class="inner_line index-main">
	    <div class="mainBOX ">
	        <div id="content">
				<div>
					<div class="chartU" ng-controller="DkggCtrl as ctrl" ng-init="ctrl.query()">
						<input type="hidden" ng-model="ctrl.kcIdsQueryParam">
						<div class="searBOX">
							<div class="inpBox">
								<span class="left">期次 ：</span>
								<select style="height:30px;padding:0 20px" ng-model="ctrl.qcQueryParam">
									<option value="0">--请选择期次--</option>
									<option ng-repeat="x in ctrl.qcs.content" value="{{x.id}}">{{x.qc}}</option>
								</select>
							</div>
							<div class="inpBox">
								<span class="left">课程名称：</span>
								<input type="text" class="inptext" class="inptext" placeholder="课程名称" ng-model="ctrl.mcQueryParam">
							</div>
							<a href="javascript:;" ng-click="ctrl.query()" type="submit" class="btn checkBtn">查询</a>
						</div>
						<div class="cooBOX">
							<a href="javascript:;" class="btn addBtn"  ng-click="export(ctrl,'root/kqc/exportKaoQinInfo')">导出考勤数据</a>
						</div>
						<table class="newTABLE">
							<thead>
							<th style="width: 3%" class="selBOX"><input ng-change="changeAll()" ng-model="selectAll" type="checkbox"></th>
							<th style="width: 27%">课程名称</th>
							<th style="width: 27%">开课时间</th>
							<th style="width: 18%">操作</th>
							</thead>
							<tr ng-repeat="item in ctrl.entities.content" ng-init="outerIndex=$index" ng-click="changeCurrents(item, $event)">
								<td class="selBOX"><input ng-model="item.checked" ng-click="changeCurrent(item, $event)" type="checkbox"></td>
								<td>{{item.kcmc}}</td>
								<td>{{item.kksj | date:'yyyy-MM-dd'}}</td>
								<td>
									<a href="javascript:;" class="btn_w clear" ng-click="ctrl.toqiandao(item)">签到</a>
									<a href="javascript:;" class="btn_w clear" ng-click="ctrl.toqiantui(item)">签退</a>
									<a href="javascript:;" class="btn_w clear" ng-click="ctrl.initkaoqin(item)">生成考勤</a>
								</td>
							</tr>
						</table>
						<div class="panel-body">
							共有记录：
							<span>{{ctrl.entities.totalElements}}</span>
							条
							<div class="pull-right" ng-include="':root/components/page.html'"></div>
						</div>
					</div>
	            </div>
			</div>
	   	</div>
	</div>
	<div id="footer_wrap"></div>
   
	<!-- js -->
	<script src="asset/outdatedbrowser/outdatedbrowser.js"></script>
    <script type="text/javascript" data-main="asset/main.js" src="asset/js/require.min.js"></script>
    <script type="text/javascript" src="asset/jquery/jquery.js"></script>
    <script type="text/javascript" src="asset/js/comm.js"></script>
    <script type="text/javascript" src="asset/js/banner.js"></script>
    <script type="text/javascript" src="asset/js/include.js"></script>

    <script>
        function DkggCtrl($injector,$scope, CtrlUtil, $element, $http,$state) {
            var back = false;
            var ctrl = this;
            ctrl.qcQueryParam = "0";

            var listUrl = ':root/kqc/listQc';
            var param = {}
            $http.post(listUrl, param).success(function (r) {
                ctrl.qcs = r;
            })

            var listUrl = ':root/kqc/listKc';
            this.query = function () {
                ctrl.entities && (ctrl.entities.content = {})
                var p = CtrlUtil.getQueryParams(ctrl)
                $http.post(listUrl, p).success(function (r) {
                    ctrl.entities = r;
                })
            }

            this.toqiandao = function (item) {
                localStorage.setItem("dakacenterKeId", item.id);
                localStorage.setItem("dakacenterKeName", item.kcmc);
                var url = 'dakacenterdao.html?id='+item.id;
                window.location.href = url;
            }

            this.toqiantui = function (item) {
                localStorage.setItem("dakacenterKeId", item.id);
                localStorage.setItem("dakacenterKeName", item.kcmc);
                var url = 'dakacentertui.html?id='+item.id;
                window.location.href = url;
            }

            this.initkaoqin = function (item) {
                var modalService = $injector.get('modalService');
                modalService.confirm({
                    content: '确定要生成课程：' + item.kcmc + ' 的考勤数据吗?',
                    result: item
                }).then(function (r) {
                    $http.post(':root/kqc/addKaoqing', {id:r.id}).success(function (R) {
                        modalService.succ('数据生成成功！您可以导出该门课程的考勤数据了。', 3000)
                        ctrl.refresh()
                        ctrl.query()
                    })
                })
            }

            //记录行单选及多选处理
            $scope.count = 0;//已选择数量
            $scope.selectData = [];//已选对象
            //选择单个（取消选择单个
            $scope.changeCurrent = function(current, $event) {
                //计算已选数量 true加， false减
                $scope.count += current.checked ? 1 : -1;
                //判断是否全选，选数量等于数据长度为true
                $scope.selectAll = $scope.count === ctrl.entities.content.length;
                //统计已选对象
                $scope.selectData = [];
                angular.forEach(ctrl.entities.content, function(item) {
                    if(item.checked){
                        $scope.selectData[$scope.selectData.length] = item.id;
                    }
                });
                $event.stopPropagation();//阻止冒泡
				ctrl.kcIdsQueryParam = $scope.selectData.toString();
            };

            //单击行选中
            $scope.changeCurrents = function(current, $event) {
                if(current.checked == undefined){
                    current.checked = true;
                }else{
                    current.checked = !current.checked;
                }
                $scope.changeCurrent(current, $event);
            };

            //全选（取消全选
            $scope.changeAll = function() {
                angular.forEach(ctrl.entities.content, function(item) {
                    item.checked = $scope.selectAll;
                    $scope.selectData[$scope.selectData.length] = item.id;
                });
                $scope.count = $scope.selectAll ? ctrl.entities.content.length : 0;
                if ($scope.selectAll) {
                    //$scope.selectData = ctrl.entities.content;
                } else {
                    $scope.selectData = [];
                }
                ctrl.kcIdsQueryParam = $scope.selectData.toString();
            };
        }
	</script>
</body>
</html>